/*
 * ui_departments.js
 *
 * JavaScript used for /admin/departments/ page.
 */

"use strict";

$(document).ready(function(){
	$('#userTable').DataTable( {
			buttons: [ {
				extend: 'colvis',
				columns: ':gt(0)'
		} ]
		, select: true
		, ajax: '/console/users/search'
		, columns: [
			{ data: "firstName" },
			{ data: 'lastName' },
			{ data: 'username', defaultContent: ''},
			{ data: 'email' }
		]
		, columnDefs: [ {
		    targets: 4,
				data: 'username',
				className: 'align-center', /* config column class name */
		    render: function ( data, type, full, meta ) {
					var template = '<ul class="table-controls">'
							+ '<li><a href="/console/users/edit/' + full.id + '" class="bs-tooltip" title="Edit"><i class="icon-pencil"></i></a> </li>'
							+ '<li><a href="/console/users/delete/' + full.id + '" class="bs-tooltip" title="Delete"><i class="icon-trash"></i></a> </li>'
							+ '</ul>'
		      return template;
		    }
		  } ]
	});
	//
	// $("#btn_employee_add").click(function(e){
	// 	//Add employee to current position
	// 	if(!currentNode) return; //currentNode not set, do nothing;
	//
	// 	$.ajax({
	// 		url: '/admin/employees/',
	// 		method: 'POST',
	// 		data: {
	// 			position: currentNode,
	// 			username: 'wjj',
	// 			lastName: '王',
	// 			firstName: '佳骏'
	// 		}
	// 	}).done(function(data, textStatus, jqXHR){
	// 		console.log(data);
	// 	}).fail(function(jqXHR, textStatus, errorThrown){
	// 		console.log(errorThrown);
	// 	});
	//
	// });


});
